package cn.iocoder.yudao.module.pplan.controller.app.recipe;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pplan.controller.app.recipe.vo.AppRecipePageReqVO;
import cn.iocoder.yudao.module.pplan.controller.app.recipe.vo.AppRecipeRespVO;
import cn.iocoder.yudao.module.pplan.service.recipe.RecipeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 生产计划-餐谱数据管理")
@RestController
@RequestMapping("/pplan/recipe")
@Validated
public class AppRecipeController {

    @Resource
    private RecipeService recipeService;


    @GetMapping("/get")
    @Operation(summary = "获得生产计划-餐谱数据管理")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppRecipeRespVO> getRecipe(@RequestParam("id") Long id) {
        AppRecipeRespVO recipeRespVO = recipeService.appGetRecipe(id);
        return success(recipeRespVO);
    }

    @GetMapping("/page")
    @Operation(summary = "获得生产计划-餐谱数据管理分页")
    public CommonResult<PageResult<AppRecipeRespVO>> getRecipePage(@Valid AppRecipePageReqVO pageReqVO) {
        PageResult<AppRecipeRespVO> pageResult = recipeService.appGetRecipePage(pageReqVO);
        return success(pageResult);
    }


}